<?php 
require_once "header_editor.php"; 
require_once "db.php"; 
require_once "forms.php"; 
require_once "util.php";

get_database_connection();

// If it is not on the passed var, it will be on the cookie setted.
$object_id = $_GET["object_id"];
if ($object_id == "") {
  $object_id = $_COOKIE["object_id"];
}

// Getting the data from the database and putting into a cookie
$sql = "SELECT * FROM objects WHERE id = $object_id";
$query = mysql_query($sql);
$data = mysql_fetch_assoc($query);

// We set a cookie representing the object_id that we are working right now.
set_cookie("object_id", $object_id);
set_cookie("object_title", $data["title"]);
?>

<div class="c6 box_header">
Slides:
</div>

<div class="c6"> <br/> </div>

<div class="c1 thead"> ID </div>
<div class="c2 thead"> Titulo </div>
<div class="c1 thead"> Posicao </div>
<div class="c2 thead"> Opcoes </div>

<?php
$sql = "SELECT * FROM slides WHERE object_id = $object_id ORDER BY position ASC";
$res = mysql_query($sql);
while ($f = mysql_fetch_assoc($res)) {
?>

<div class="c1 td"> <?php echo $f['id']; ?> </div>
<div class="c2 td"> <?php echo $f['title'] ?></div>
<div class="c1 td"> <?php echo $f['position'] ?></div>
<div class="c2 td"> 

<a href="#" id="visualizar" tip="Clique para visualizar o slide">
<img id="im" width="16px" src="images/blue-folder-horizontal-open.png"  />
</a> 

<a href="edit_slide.php?id=<?php echo $f['id']; ?>" id="visualizar" tip="Editar o slide">
<img id="im" width="16px" src="images/edit-signiture.png"  />
</a> 


</div>

<?php
}
?>


<?php require_once "footer.php"; ?>
